<%@ taglib prefix="v-bind" uri="http://www.springframework.org/tags/form" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <title>修改权限</title>

    <jsp:include page="../comm/comm.jsp"/>
</head>
<body>
  <input type="hidden" value="${roleId}" id="roleId"/>
<form class="layui-form" action="">

    <div id="app">

        <template v-for="data in sites">
            <template v-if="data.parentId==0">
    </div> <div class="layui-input-block" style="min-height:10px">

        </template>
            <template v-if="data.resourceId!=null">
            <input type="checkbox" name="like" v-bind:title="data.resuorceName" checked v-bind:id="data.id">
            </template>
            <template v-if="data.resourceId==null">
                <input type="checkbox" name="like" v-bind:title="data.resuorceName" v-bind:id="data.id">
            </template>
        <template v-if="data.parentId==0">

    </div><div class="layui-input-block" style="min-height:10px;">
        </template>
        </template>

        <%--<div class="layui-input-block">--%>
            <%--<template v-for="data in datas">--%>

                <%--<template v-if="{{data.resourceId}}!=null">--%>
                    <%--<input type="checkbox" name="like[write]" title="{{data.resuorceName}}" checked>--%>
                <%--</template>--%>
                <%--<template v-if="{{data.resourceId}}==null">--%>
                    <%--<input type="checkbox" name="like[write]" title="{{data.resuorceName}}">--%>
                <%--</template>--%>
                <%--<template v-if="{{data.resourceId}}==0">--%>
                   <%--</div><div class="layui-input-block">--%>
                <%--</template>--%>
            <%--</template>--%>
              <%--</div>--%>
    </div>
    <button class="layui-btn" lay-submit lay-filter="formDemo" id="modify">立即提交</button>
</form>
<script type="text/javascript" src=" //cdn.bootcss.com/vue/2.2.2/vue.min.js"></script>
<script type="text/javascript">
   var  roleId=$("#roleId").val();
    //Demo
    layui.use('form', function(){
        var form = layui.form;
        config.commGet("/role/findRoleVo.json?roleId="+roleId,{},function (data) {
            new Vue({
                el: '#app',
                data: {
                    sites: data
                }
            })
            form.render();
        });

        //监听提交
        form.on('submit(formDemo)', function(data){
            var emps= $("input[name='like']:checked");
            var ids="";
            for (var i=0;i<emps.length;i++){
                ids+=emps[i].id+",";
            }
           ids=ids.substring(0,ids.length-1);
            config.commPost("/role/save.json",{roleId:roleId,ids:ids},function (data) {
               alert("成功");
            });
            return false;
        });
    });
</script>

</body>
</html>
